package com.mantru.iotpot.Dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import com.mantru.iotpot.R;

public class DeleteStepDialog extends Dialog {
    Context context;
    private TextView confirm;
    private TextView cancel;
    private ImageView close;
    private DeleteStepDialogListener deleteStepDialogListener;
    public void setDeleteStepDialogListener(DeleteStepDialogListener deleteStepDialogListener){
        this.deleteStepDialogListener = deleteStepDialogListener;
    }
    public interface DeleteStepDialogListener{
        void confirm();
    }

    public DeleteStepDialog(Context context, int theme){
        super(context, theme);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.dialog_delete_step_tip);

        initView();//set my control here
        setDialogCancelable();//set dialog cancelable or not
        setDialogListener();
    }

    //set my control here
    private void initView(){
        confirm = findViewById(R.id.dialog_delete_step_confirm);
        close = findViewById(R.id.dialog_delete_step_close);
        cancel = findViewById(R.id.dialog_delete_step_cancel);
    }

    private void setDialogCancelable(){
        this.setCancelable(true);
    }

    private void setDialogListener(){
        confirm.setOnClickListener(v -> {
            deleteStepDialogListener.confirm();
            dismiss();
        });
        cancel.setOnClickListener(v -> dismiss());
        close.setOnClickListener(v -> dismiss());
    }
}
